FROM jenkins/jenkins:lts
MAINTAINER "Mr_He"<HelloHeSir@gmail.com>

USER root
WORKDIR /usr

RUN echo '' > /etc/apt/sources.list.d/jessie-backports.list \
  && echo "deb http://mirrors.aliyun.com/debian jessie main contrib non-free" > /etc/apt/sources.list \
  && echo "deb http://mirrors.aliyun.com/debian jessie-updates main contrib non-free" >> /etc/apt/sources.list \
  && echo "deb http://mirrors.aliyun.com/debian-security jessie/updates main contrib non-free" >> /etc/apt/sources.list

RUN apt-get update && apt-get install -y sudo && apt-get install -y libltdl7 && rm -rf /var/lib/apt/lists/* \
  && echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers

ARG dockerGid=999

RUN echo "docker:x:${dockerGid}:jenkins" >> /etc/group

COPY plugins.txt /usr/share/jenkins/ref/plugins.txt
RUN /usr/local/bin/install-plugins.sh < /usr/share/jenkins/ref/plugins.txt

ENV MAVEN_URL="http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.6.0/binaries/apache-maven-3.6.0-bin.tar.gz"

RUN wget $MAVEN_URL -O maven.tar.gz \
	&& tar -xzvf maven.tar.gz \
	&& mv apache-maven-3.6.0 maven3 \
	&& ln -s /usr/maven3/bin/mvn /usr/bin/mvn \
  && rm -f /usr/maven.tar.gz

EXPOSE 8080 50000